﻿using StudentsInfor.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace StudentsInfor.Services
{
    public class StuService
    {
        /// <summary>
        /// 输出所需信息
        /// </summary>
        /// <param name="students"></param>
        public static void OutputInfor(List<Student>students)
        {
            //计算平均分
            double average = students.Average(m => m.Grade);
            Console.WriteLine("班级平均分是{0}", average);
            //记录最高最低分信息
            int max = students.Max(m => m.Grade);
            foreach (var st in students)
            {
                if (st.Grade == max)
                    Console.WriteLine("最高分的姓名是{0}，其学号是{1},手机号是{2}，成绩是{3},出生日期是{4},年龄是{5}", st.Name, st.Number, st.Mobile, st.Grade, st.Birth, st.Age);
            }
            int min = students.Min(m => m.Grade);
            foreach (var st in students)
            {
                if (st.Grade == min)
                    Console.WriteLine("最低分的姓名是{0}，其学号是{1},手机号是{2}，成绩是{3},出生日期是{4},年龄是{5}", st.Name, st.Number, st.Mobile, st.Grade, st.Birth, st.Age);
            }
        }
    }
}
